package com.shengtsource.minicat.util;

import java.io.InputStream;

/**
 * Http协议工具类
 * @author shengtsource
 */
public class HttpProtocolUtils {

    /**
     * 构建响应码为200响应头信息
     * @param contentLength
     * @return
     */
    public static String getResponseHeader200(long contentLength) {
        return "HTTP/1.1 200 OK \n" +
                "Content-Type: text-html;charset=utf-8 \n" +
                "Content-Length: " + contentLength + "\n" +
                "\r\n";
    }

    /**
     * 构建响应码为404响应头信息
     * @return
     */
    public static String getResponseHeader404() {
        String htmlOf404 = "<h1>404 Not Found</h1>";
        return "HTTP/1.1 200 OK \n" +
                "Content-Type: text-html;charset=utf-8 \n" +
                "Content-Length: " + htmlOf404.getBytes().length + "\n" +
                "\r\n" +
                htmlOf404;
    }
}
